# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Alad Wenter <alad@mailbox.org>
# Contributor: Eric Biggers <ebiggers3 at gmail dot com>

pkgname=wimlib
pkgver=1.14.0
pkgrel=1
pkgdesc='A library and program to extract, create, and modify WIM files'
arch=('loong64' 'x86_64')
url='https://wimlib.net'
license=('custom')
depends=('fuse3' 'ntfs-3g')
checkdepends=('attr')
optdepends=(
  'cdrkit: for making ISO image of Windows PE'
  'mtools: for making disk image of Windows PE' 
  'syslinux: for making disk image of Windows PE'
  'cabextract: for extracting Windows PE from the WAIK'
)
provides=('libwim.so')
source=("https://wimlib.net/downloads/$pkgname-$pkgver.tar.gz")
sha512sums=('b97abb9e7b6d0adab336efa7589582dd1f2ffe145a8d146735a5f85de14ae9a4a3ca689c85b57b55ffd1a857338ace49f792280f4b71df76065373a633e47e6d')
b2sums=('d9efb3ffc59ef2ecd5ed40e4e963f1307417a776fa3544d50179257831cf311fec9fa8bdd82f0901c3e3d9700c94cf26b4775fe485a2a9691a7f392ed0267f15')

build() {
  cd "$pkgname-$pkgver"

  ./configure \
    --disable-static \
    --with-libcrypto \
    --with-fuse \
    --with-ntfs-3g \
    --prefix=/usr

  make
}

check() {
  cd "$pkgname-$pkgver"

  make check
}

package() {
  cd "$pkgname-$pkgver"

  make DESTDIR="$pkgdir" install

  # documentation
  install -Dm644 {NEWS,README}.md -t "$pkgdir/usr/share/doc/$pkgname"

  # licenses
  install -Dm644 COPYING* -t "$pkgdir/usr/share/licenses/$pkgname"
}
